package com.onec.service.manage.service.kafka;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.MimeTypeUtils;

/**
 * 卡法卡 sendservice
 */
@EnableBinding(ExamFinishOutputChannel.class)
public class SendFinishService {

    @Autowired
    private ExamFinishOutputChannel examFinishOutputChannel;

    public void sendMsg(String message) {
        System.out.println("exam-finish-output 发送消息：" + message);
        boolean result = examFinishOutputChannel.sendFinishChannel()
                .send(MessageBuilder.withPayload(message)
                        .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON_VALUE)
                        .build());
        System.out.println("exam-finish-output 执行结果：" + result);
    }
}
